package com.todo.delicacy.application.frontend.controller;


import com.todo.common.common.entity.response.BizResponse;
import com.todo.delicacy.application.frontend.service.FoodInfoAggService;
import com.todo.delicacy.iface.frontend.FoodInfoFrontendIface;
import com.todo.delicacy.iface.frontend.request.QueryFoodDetailParam;
import com.todo.delicacy.iface.frontend.request.QueryFoodListByNameParam;
import com.todo.delicacy.iface.frontend.request.QueryFoodListByRestaurantParam;
import com.todo.delicacy.iface.frontend.response.FoodBaseVO;
import com.todo.delicacy.iface.frontend.response.FoodDetailVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author azhebuxing
 * @date 2024/6/4 20:46
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/food")
@Tag(name = "美食前台接口", description = "美食前台接口")
public class FoodInfoFrontendController implements FoodInfoFrontendIface {

    @Resource
    private FoodInfoAggService foodInfoAggService;


    @Override
    @Operation(summary = "根据餐厅id查询美食列表")
    @PostMapping("/queryFoodListByRestaurantId")
    public BizResponse<List<FoodBaseVO>> queryFoodListByRestaurantId(QueryFoodListByRestaurantParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return foodInfoAggService.queryFoodListByRestaurantId(param);
    }

    @Override
    @Operation(summary = "根据名称查询美食列表")
    @PostMapping("/queryFoodListByName")
    public BizResponse<List<FoodBaseVO>> queryFoodListByName(QueryFoodListByNameParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return foodInfoAggService.queryFoodListByName(param);
    }

    @Override
    @Operation(summary = "根据Id查询美食详情")
    @PostMapping("/queryFoodDetailById")
    public BizResponse<FoodDetailVO> queryFoodDetailById(QueryFoodDetailParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return foodInfoAggService.queryFoodDetailById(param);
    }
}
